package com.woniuxy.business.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.business.service.ActivityService;
import com.woniuxy.commons.entity.Activity;
import com.woniuxy.commons.entity.QueryEntity;
import com.woniuxy.commons.service.MedicineService;
import com.woniuxy.commons.utils.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 雷珉
 * @date 2022年06月08日 16:41
 */
@RestController
@RequestMapping("/business/activity")
public class ActivityController {
    @Resource
    private ActivityService activityService;

    @GetMapping("/")
    public ResponseResult<List<Activity>> findAll(){
        return activityService.findAll();
    }

    @PostMapping("/condition")
    public ResponseResult<PageInfo<Activity>> findAllByCondition(@RequestBody QueryEntity<Activity> queryEntity){
        return activityService.findAllByCondition(queryEntity);
    }

    @GetMapping("/{id}")
    public ResponseResult<Activity> findOne(@PathVariable("id") int id){
        return activityService.findOne(id);
    }

    @PostMapping("/")
    public ResponseResult addOne(@RequestBody Activity activity){
        return activityService.addOne(activity);
    }

    @PutMapping("/")
    public ResponseResult updateOne(@RequestBody Activity activity){
        return activityService.updateOne(activity);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteOne(@PathVariable("id") int id){
        return activityService.deleteOne(id);
    }

    @PostMapping("/batchDel")
    public ResponseResult deleteBatch(@RequestBody int[] ids){
        return activityService.deleteBatch(ids);
    }
}

